package com.sofwin.yyb.service.impl;

import com.sofwin.yyb.dao.CourseDao;
import com.sofwin.yyb.dto.CourseDto;
import com.sofwin.yyb.entity.Appointment;
import com.sofwin.yyb.entity.Course;
import com.sofwin.yyb.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("servicesService")
public class CourseServiceImpl implements CourseService {

    @Autowired
    CourseDao courseDao;

    @Override
    public List<Course> findAll(Integer type) {
        List<Course> list = courseDao.selectServiceList(type);
        return list;
    }

    @Override
    public Course findById(Integer id) {
        return courseDao.selectServiceById(id);
    }

    @Override
    public void addOrder(Appointment order) {
        courseDao.insertOrder(order);
    }

    @Override
    public void addService(Course services) {
        courseDao.insertService(services);
    }

    @Override
    public List<CourseDto> findAllCourse(Map<String, Object> map) {
        return courseDao.selectAllCourse(map);
    }

    @Override
    public Integer courseCount(String search) {
        return courseDao.courseCount(search);
    }

    @Override
    public boolean updateCourseStatus(Map<String,Object> map) {
        Integer i = courseDao.updateCourseStatus(map);
        if(i>0){
            return true;
        }
        return false;
    }
}
